package controller

import (
	"github.com/gin-gonic/gin"
	"system-admin/internal/messageJSON"
	"system-admin/internal/service"
)

// operation for Blog
type blogController struct{}

// 获取控制器对象
func GetBlogController() (blogController *blogController) {
	return blogController
}

// 获取博客文章N条和相关用户数据
func (b *blogController) GetBlogEssayAndUserHandler(c *gin.Context) {
	blogService := service.GetBlogService()
	blogList, userList, result, row := blogService.BlogEssayInLimitAndUser()

	if result == true {
		//如果查询到说明获取到了
		messageJSON.GetBlogEssayAndUserOK(c, blogList, userList, row)
	} else {
		//查询不到
		messageJSON.GetBlogEssayAndUserFail(c)
	}
	return
}
